﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Media;
using System.Text;
using System.Drawing;
using System.Windows.Forms;
using System.Collections;

/* Authors: Mike Poddo, Matt Gillette
 * Missile Command
 */

namespace MissileCommand
{
    class Cities
    {
        private Graphics g;
        private SolidBrush mybrush;
        private int numCitiesRemaining;
        private Rectangle rCityOne;
        private Boolean cityOne= true;
        private Rectangle rCityTwo;
        private Boolean cityTwo = true;
        private Rectangle rCityThree;
        private Boolean cityThree = true;
        private Rectangle rCityFour;
        private Boolean cityFour = true;
        private Rectangle rCityFive;
        private Boolean cityFive = true;
        private Rectangle rCitySix;
        private Boolean citySix = true;
        private Point[] Points = new Point[] { new Point(94, 308), new Point(126, 308), new Point(155, 308), new Point(235, 308), new Point(268, 308), new Point(306, 308) };
        private SoundPlayer sp = new SoundPlayer("sounds/cityexpl.wav");

        public Cities(Graphics g)
        {
            this.g = g;
            this.numCitiesRemaining = 6;
            rCityOne = new Rectangle(Points[0].X, Points[0].Y,8,8);
            rCityTwo = new Rectangle(Points[1].X, Points[1].Y, 8, 8);
            rCityThree = new Rectangle(Points[2].X, Points[2].Y, 8, 8);
            rCityFour = new Rectangle(Points[3].X, Points[3].Y, 8, 8);
            rCityFive = new Rectangle(Points[4].X, Points[4].Y, 8, 8);
            rCitySix = new Rectangle(Points[5].X, Points[5].Y, 8, 8);
            mybrush = new SolidBrush(Color.Blue);
        }

        public int CitiesAccessor
        {
            get
            {
                return numCitiesRemaining;
            }
            set
            {
                numCitiesRemaining = value;
            }
        }


        public void drawCities()
        {
            if (cityOne)
                g.FillRectangle(mybrush, rCityOne);
            if(cityTwo)
                g.FillRectangle(mybrush, rCityTwo);
            if(cityThree)
                g.FillRectangle(mybrush, rCityThree);
            if(cityFour)
                g.FillRectangle(mybrush, rCityFour);
            if(cityFive)
                g.FillRectangle(mybrush, rCityFive);
            if(citySix)
                g.FillRectangle(mybrush, rCitySix);

        }

        public void CityRemove(int index)
        {
            switch (index)
            {
                case 0:
                    if(cityOne)//city still there
                    {
                        
                        sp.Play();
                        cityOne = false;
                        numCitiesRemaining--;
                        break;
                    }
                    break;
                case 1:
                    if(cityTwo)
                    {
                        sp.Play();
                        cityTwo = false;
                        numCitiesRemaining--;
                        break;
                    }
                    break;
                case 2:
                    if(cityThree)
                    {
                        sp.Play();
                        cityThree = false;
                        numCitiesRemaining--;
                        break;
                    }
                    break;
                case 3:
                    if(cityFour)
                    {
                        sp.Play();
                        cityFour = false;
                        numCitiesRemaining--;
                        break;
                    }
                    break;
                case 4:
                    if(cityFive)
                    {
                        sp.Play();
                        cityFive = false;
                        numCitiesRemaining--;
                        break;                 
                    }
                    break;
                case 5:
                    if(citySix)
                    {
                        sp.Play();
                        citySix = false;
                        numCitiesRemaining--;
                        break;
                    }
                    break;

            }

        }

    }
}
